	/*
	订单项
		商户项 add
			商品类项
	Order {方法：makeHTML}

	Item {属性：caption 方法：makeHTML}
	Business Item的子类 {属性：caption 方法：makeHTML}
	Goods Item的子类 {属性： 方法makeHTML}

	Factory
		createBusiness
		createOrder
		createGoods
	*/
	//父类
	function OrderAndBusiSuper (){
		this.list = new ArrayList() ;
		this.add = function (goods){
			this.list.add(goods) ;
		}
		this.makeHTML = function (){
			//代码拼接
			var goodsStrs = this.headCode() ;
			var it = this.list.itarator() ;
			while(it.hasNext()){
				goodsStrs += it.next().makeHTML() ;
			}
			return goodsStrs += this.bomCode() ;
		}
		this.headCode = function (){}
		this.bomCode = function(){}
	}

	//子类
	Order_1.extends(OrderAndBusiSuper) ;
	function Order_1 (data){
		//订单编号 下单时间 金额 
		OrderAndBusiSuper.call(this) ;
		this.headCode = function (){
			return '<div class="order" data-id="' + data.get("id") + '"><div class="top"><label>订单编号：'+data.getRe("id")+'</label>&nbsp;&nbsp;<label>时间：'+data.getRe("time")+'</label></div><div class="con"><ul>' ;
		}
		this.bomCode = function(){
			return '</ul></div><div class="bom"><label class="money_space">&nbsp;&nbsp;</label><label class="money">金额：'+data.getRe("money")+'元</label><label class="money_space">&nbsp;&nbsp;</label><label class="original_money"><del style="font-size:6px;">原价：200元</del></label></div><div style="clear:both;"></div></div>' ;
		}
	}
	//用于用户订单
	Business_1.extends(OrderAndBusiSuper) ;
	function Business_1 (data){
		//商家名称 deliveryState是否发货 progressState是否完成交易 物流信息{} 发送地址 deliveryAddress 
		OrderAndBusiSuper.call(this) ;
		this.headCode = function (){
			return '<li><div class="busi_name"><label style="text-align:none;">'+data.getRe("storeName")+'</label></div><table cellspacing="0" cellpadding="0"><tbody>' ;
		}
		this.bomCode = function(){
			var loginstics_data = data.getRe("logistics") ;
			var bomStr = '' ;
			var tempStr = '<div class="order_logistics"><label>'+loginstics_data.getRe("shipAddress")+'&nbsp;(发货地址)</label><label><i style="background:url(image/to.png);"></i></label><label>'+loginstics_data.getRe("receiptAddress")+'&nbsp;(收货地址)</label><label class="sure_order">确认收货</label></div>' ;
			if(data.getRe("deliveryState") == "true"){
				if(data.getRe("progressState") == "true"){	//进度
					bomStr = '<div class="order_state">'+this.code_2 ("订单完成")+'</div>' ;
				}else{
					bomStr = '<div class="order_state">'+this.code_2 ("正在发货")+'</div>' ;
				}
				bomStr += tempStr ;
			}else{
				bomStr = '<div class="order_state">'+this.code_1 ()+'</div>' ;
			}
			return '</tbody></table><div class="li_bom">'+bomStr+'</div></li>' ;
		}
		this.code_1 = function (){
			return '<label>&nbsp;&nbsp;&nbsp;&nbsp;</label><label>等待订单确认</label>' ;
		}
		this.code_2 = function (desc){
			return '<label>&nbsp;&nbsp;&nbsp;&nbsp;</label><label class="label_logistics">查看物流信息</label><label>&nbsp;&nbsp;&nbsp;&nbsp;</label><label>'+desc+'</label><div style="clear:both;"></div>' ;
		}
	}
	//用于商户管理订单
	Business_2.extends(Business_1) ;
	function Business_2 (data){
		// deliveryState是否发货 progressState是否完成交易 物流信息{} 发送地址 deliveryAddress 
		Business_1.call(this) ;
		var logist = data.get("logistics") ;
		
		this.headCode = function (){
			return '<li><table cellspacing="0" cellpadding="0"><tbody>' ;
		}
		this.bomCode = function(){
			var loginstics_data = data.getRe("logistics") ;
			var bomStr = '' ;
			var tempStr = '<div class="order_logistics"><label data-id="">'+loginstics_data.getRe("shipAddress")+'&nbsp;(发货地址)</label><label><i style="background:url(image/to.png);"></i></label><label data-id="">'+loginstics_data.getRe("receivAddress")+'&nbsp;(收货地址)</label><label class="sure_order">确认收货</label></div>' ;
			if(data.getRe("deliveryState")){
				if(data.getRe("progressState"))	//进度
					bomStr = '<div class="order_state">'+this.code_2("订单完成")+'</div>' + this.addCode("") ;
				else
					bomStr = '<div class="order_state">'+this.code_2("正在发货")+'</div>' + this.addCode("") ;
				bomStr += tempStr ;
			}else
				bomStr = '<div class="order_state">'+this.code_1 ()+'</div>' + this.addCode('<label class="sure_order" style="">确认发货</label>', code_1_1()) ;
			return '</tbody></table><div class="li_bom">'+bomStr+'</div></li>' ;
		}
		//策略1 progressState = false时 即未发货
		this.code_1 = function (){
			return '<label>&nbsp;&nbsp;&nbsp;&nbsp;</label>' +
					'<label class="more_infor">进行发货确认</label>' +
					'<label>&nbsp;&nbsp;&nbsp;&nbsp;</label>' +
					'<label>等待确认</label>' ;
		} 
		this.code_1_1 = function(){  //即未发货 选择发货地址代码
 			var str = '<select class="select_address" style="width: 200px; height: 25px; bakcground: #ccc; "><option>选择发货地址</option>'+ _merchantAddress() +'</select>'
			return str ;
		}
		//策略2 progressState = true时 即已发货
		this.code_2 = function (desc){
			return '<label>&nbsp;&nbsp;&nbsp;&nbsp;</label><label class="more_infor">查看物流信息</label><label>&nbsp;&nbsp;&nbsp;&nbsp;</label><label>'+desc+'</label><div style="clear:both;"></div>' ;
		}
		//隐藏代码 desc - '<label class="sure_order" style="">确认发货</label>'
		//广东省 广州市 广东白云学院&nbsp;(发货地址) 发货地址格式
		this.addCode = function(desc, codeStr){
			return '<div class="order_logistics">' +
						'<label class="ship_address" data-id="">'+(codeStr != undefined ? codeStr : logist.get("shipAddress"))+'&nbsp;(发货地址)</label>' +
						'<label><i style="background:url(image/to.png);"></i></label>' +
						'<label class="receiv_address" data-id="">'+logist.get("receiAddress")+'&nbsp;(收货地址)</label>' + desc +
					'</div>' ;
		}
		function _merchantAddress(){
			var html = "" ;
			var arrObj = data.get("address") ;
			var it = arrObj.itarator() ;
			while(it.hasNext()) {
				var obj = it.next() ;
				html += '<option data-id="' + obj.get("id") + '">'+ obj.get("text") +'</option>'
			}
			return html ;
		}
	}
	function Goods_1 (data){
		this.makeHTML = function(){
			//商品编号 图片 名称 尺码 单价 数量
			return '<tr data-id=""><td><img src="../'+data.getRe("path")+'" width="100px" height="110px" alt="'+data.getRe("name")+'" /></td><td class="goods_name">'+data.getRe("name")+'</td><td class="goods_color">'+data.getRe("color")+'</td><td class="goods_size">'+data.getRe("size")+'</td><td class="goods_count">'+data.getRe("count")+'</td><td class="goods_price">'+data.getRe("price")+'元</td></tr>' ; //代码
								/*return '<div class="lictn" data-id="">'+
									'<label class="goodspho">'+
										'<img src='+data.getRe("path")+' width="55" height="60" />'+
									'</label>'+
									'<label class="goodsdes">'+
										'<label class="goods-infor">'+
										'	<label class = "goods-name">'+data.getRe("name")+'</label>'+
										'	<label class="goods-color">'+data.getRe("color")+'</label>'+
										'	<label class="goods-num">'+data.getRe("count")+'</label>'+
										'	<label class="goods-size">'+data.getRe("size")+'</label>'+
										'	<label class="goods-price"><del>110</del>'+data.getRe("price")+'</label>'+
										'</label>'+
									'</label>'+
								'</div>' ;*/
		}
	}
	/*
	一种风格的工厂
	*/
	function OrderFactory_1(){
		this.createOrder = function (data){
			return new Order_1(data) ;
		}
		this.createBusiness = function (data){
			return new Business_1(data) ;
		}
		this.createBusinessUser = function (data){
			return new Business_1(data) ;
		}
		this.createBusinessMange = function (data){
			return new Business_2(data) ;
		}
		this.createGoods = function (data){
			return new Goods_1(data) ;
		}
	}
	